
;	MOVFF	SPORT,SPORT_TEMP 		;STORE OUR WORK VARAIBLE
;	;NOP
;;;;;;;;;;;;;;;;;;;START BIT CHECK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;	;;CHECK FOR A START BIT( FALLING EDGE ON DATA WITH CLOCK HIGH)
;	COMF 	SPORT_TEMP,W,A 			; WREG CONTAINS !DATA
;	ANDWF 	LAST_SDAT,W,A			; WREG CONTAINS LAST_SDAT & !DATA
;	BZ 		DONE_START_BIT_CHECK
;		
;	BTFSS	SPORT_TEMP,SCLK,A		; CHECK TO SEE IF THE CLOCK LINE IS HIGH
;	BRA		DONE_START_BIT_CHECK
;	
;	;;WE HAVE FOUND A START BIT, INFORM COMPUTER
;	MOVF	TX_STATE,F,A			;SEE IF BUFFER ALREADY HAS DATA
;	BNZ		SEND_START_BIT_TO_NEXT_STATE
;	
;	MOVLW 	UART_TX_START_BIT	
;	MOVWF 	TX_STATE,A
;	BRA		START_BIT_RESET_SHIFT_BUFFER
;	
;SEND_START_BIT_TO_NEXT_STATE:
;	MOVLW 	UART_TX_START_BIT	
;	MOVWF 	TX_STATE_NEXT,A
;	
;START_BIT_RESET_SHIFT_BUFFER:
;	;AND RESET ONGOING SHIFTING
;	MOVLW 	REQUIRED_BITS
;	MOVWF 	SHIFT_COUNT
;DONE_START_BIT_CHECK:
;;;;;;;;;;;;;;;;;;;START BIT CHECK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;;;;;;;;;;;;;;;;;;;STOP BIT CHECK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;	;;CHECK FOR A STOP BIT( RISING EDGE ON DATA WITH CLOCK HIGH)
;	COMF 	SPORT_TEMP,W,A 			; WREG CONTAINS !DATA
;	ANDLW	SDAT_MASK			; MASK TO ONLY CONTAIN DATA
;	IORWF 	LAST_SDAT,W,A		; WREG CONTAINS LAST_SDAT & !DATA
;	BNZ 	DONE_STOP_BIT_CHECK
;		
;	BTFSS	SPORT_TEMP,SCLK,A		; CHECK TO SEE IF THE CLOCK LINE IS HIGH
;	BRA		DONE_STOP_BIT_CHECK
;	
;	;;WE HAVE FOUND A STOP BIT, INFORM COMPUTER
;	MOVF	TX_STATE,F,A			;SEE IF BUFFER ALREADY HAS DATA
;	BNZ		SEND_STOP_BIT_TO_NEXT_STATE
;	
;	MOVLW 	UART_TX_STOP_BIT	
;	MOVWF 	TX_STATE,A
;	BRA		STOP_BIT_RESET_SHIFT_BUFFER
;	
;SEND_STOP_BIT_TO_NEXT_STATE:
;	MOVLW 	UART_TX_STOP_BIT	
;	MOVWF 	TX_STATE_NEXT,A
;	
;STOP_BIT_RESET_SHIFT_BUFFER:	
;	;AND RESET ONGOING SHIFTING
;	MOVLW 	REQUIRED_BITS
;	MOVWF 	SHIFT_COUNT	
;DONE_STOP_BIT_CHECK:
;;;;;;;;;;;;;;;;;;;STOP BIT CHECK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;;15 inst critical path
;
;;;;;;;;;;;;;;;;;;;DATA CHECK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;	;;CHECK FOR A DATA BIT( RISING EDGE ON CLOCK )
;	COMF 	SPORT_TEMP,W,A 			; WREG CONTAINS !SCLK
;	ANDLW	SCLK_MASK				; MASK TO ONLY CONTAIN !SCLK
;	IORWF 	LAST_SCLK,W,A			; WREG CONTAINS LAST_SCLK & !SCLK
;	BNZ 	DONE_DATA_BIT_CHECK
;	
;	;;WE HAVE FOUND A DATA BIT, NOW SAVE IT
;	BCF		STATUS,C,A
;	BTFSC	SPORT_TEMP,SDAT,A
;	BSF		STATUS,C,A			;PUT THIS BIT IN THE CARRY FLAG
;	
;	RLCF	SHIFT_BUFFER,F,A	;AND SHIFT IT INTO OUR BUFFER
;	DCFSNZ	SHIFT_COUNT,F,A		;KEEP TRACK OF THE NUMBER OF BITS
;	BRA 	DONE_DATA_BIT_CHECK	;IF WE NEED MORE BITS, SKIP THIS PART
;	
;	;8 BITS RECEIVED, RESET COUNT
;	MOVLW 	REQUIRED_BITS
;	MOVWF 	SHIFT_COUNT,A
;	
;	;HANDLE SEND
;	MOVFF 	SHIFT_BUFFER,TX_CHAR_0
;	;NOP
;	
;	MOVF	TX_STATE_0,F,A			;SEE IF BUFFER ALREADY HAS DATA
;	BNZ		SEND_HEAD_TO_NEXT_STATE
;	
;	MOVLW 	UART_TX_CHAR_HEAD	;IF IT DOESNT, SIMPLY PUT THE DATA IN THE FIRST BUFFER
;	MOVWF 	TX_STATE_0,A
;	BRA		DONE_DATA_BIT_CHECK
;	
;SEND_HEAD_TO_NEXT_STATE:		;IF IT DOES, PUT THE DATA IN THE NEXT BUFFER
;	MOVLW 	UART_TX_CHAR_HEAD	
;	MOVWF 	TX_STATE_1,A
;	
;	;35 INST CRITICAL PATH	
;DONE_DATA_BIT_CHECK:
;;;;;;;;;;;;;;;;;;;DATA CHECK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



;;;;;;;;;;;;;;;;;;;UPDATE LAST KNOWN VARIABLES;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;	MOVLW	SDAT_MASK			; MASK ONLY DATA
;	ANDWF	SPORT_TEMP,W,A
;	MOVWF	LAST_SDAT,A			; UPDATE THE LAST DATA VARIABLE
;;;;;;;;;;;;;;;;;;;UPDATE LAST KNOWN VARIABLES;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	;38 INST CRITICAL PATH (RECEIVE) CHAR	
	;19 MIN